using System.Collections;
using System.Collections.Generic;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class GetPawnProperty : MonoBehaviour
{
    //private Property property;
    //public GameObject name;
    public GameObject HP;
    public GameObject Atk;
    public GameObject DFD;
    //public GameObject Range;
    //public GameObject Speed;

    public TextMeshProUGUI HPval;
    public TextMeshProUGUI Atkval;
    public TextMeshProUGUI Defval;

    public Property pawnpro;
    private Card card;
    // Start is called before the first frame update
    void Start()
    {
        pawnpro = this.GetComponentInParent<Property>();
        //Debug.Log(pawnpro);
    }

    public bool ifUpdate = true;

    // Update is called once per frame
    void Update()
    {
        //�Ȳ�д���������Ҫ�������ص��Ļ���������ķ���
        if (ifUpdate)
            UpdateProperty();
    }

    public void UpdateProperty()
    {
        HPval.text = pawnpro.HealPoint <= 0 ? "0" : pawnpro.HealPoint.ToString();
        Atkval.text = pawnpro.Attack <= 0 ? "" : pawnpro.Attack.ToString();
        Defval.text = pawnpro.Defence <= 0 ? "" : pawnpro.Defence.ToString();
        if (pawnpro.Defence <= 0)
        {
            DFD.SetActive(false);
        }
        else
        {
            DFD.SetActive(true);
        }
    }

    public void UpdateProperty(float hp, float atk, float def)
    {
        HPval.text = hp <= 0 ? "0" : hp.ToString();
        Atkval.text = atk <= 0 ? "" : atk.ToString();
        Defval.text = def <= 0 ? "" : def.ToString();
        if (def <= 0)
        {
            DFD.SetActive(false);
        }
        else
        {
            DFD.SetActive(true);
        }
    }
}
